package com.jianglin.mapper;

import com.jianglin.model.PropertyType;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface PropertyTypeMapper{
    @Select("SELECT * FROM property_type")
    List<PropertyType> findAll();

    @Select("SELECT * FROM property_type WHERE id = #{id}")
    PropertyType findById(Long id); // 改为 Long

    @Insert("INSERT INTO property_type(name, price, unit, remarks) " +
            "VALUES(#{name}, #{price}, #{unit}, #{remarks})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(PropertyType propertyType);

    @Update("UPDATE property_type SET name=#{name}, price=#{price}, " +
            "unit=#{unit}, remarks=#{remarks} WHERE id=#{id}")
    int update(PropertyType propertyType);

    @Delete("DELETE FROM property_type WHERE id = #{id}")
    int delete(Long id); // 改为 Long


}
